package com.hxl.tech.gateway.auth.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

@Data
public class PageRequest {

    @ApiModelProperty(value = "分页页码", name = "page_number", required = true)
    @Min(1)
    private Integer pageNumber;

    @ApiModelProperty(value = "分页大小", name = "page_size", required = true)
    @Max(100)
    private Integer pageSize;

    @ApiModelProperty(value = "排序", name = "property", required = false)
    private String property;

    @ApiModelProperty(value = "排序(asc|desc)", name = "direction", required = false)
    private String direction;

    public Integer limit(){
        return pageSize;
    }

    public Long offset(){
        return ((long) (pageNumber - 1) * pageSize);
    }
}
